//申请加入帮派
// @ts-ignore
export async function execute(client_id,message_json) {
    let characters = G.Characters.get_current_login_characters(client_id);
    let gang_id = message_json["编号"];
    if (_GangDataCache.has(characters["BPID"])) {
        ClientUtils.send_basic_prompt(client_id, "你已经有一个帮派了");
        return;
    }
    let gang_data = _GangDataCache.get(gang_id);
    if (gang_data === undefined) {
        ClientUtils.send_basic_prompt(client_id, "申请的帮派不存在或已解散");
        return;
    }
    if (gang_data["成员数量"]["当前"] >= gang_data["成员数量"]["上限"]) {
        ClientUtils.send_basic_prompt(client_id, "帮派已满员");
        return;
    }
    for (let index = 0; index < gang_data["申请人员"].length; index++) {
        const member = gang_data["申请人员"][index];
        if (member["id"] === characters["id"]) {
            ClientUtils.send_basic_prompt(client_id, "你已在申请队列中……");
            return;
        }

    }
    gang_data["申请人员"].push({
        "名称": characters["名称"],
        "id": characters["id"],
        "等级": characters["等级"],
        "门派": characters["门派"],
        "申请时间": Math.floor(Date.now() / 1000),
    });
    ClientUtils.send_basic_prompt(client_id, "申请加入中请耐心等待……");
    G.GangUtils.notice_gang_chat(gang_id, "[帮派总管]#R/有新的玩家正在申请入帮，请及时处理！");
}
